home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10510 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: airdmhor.gen.nz!not-for-mail
  2. From: gumboot@airdmhor.gen.nz (Simon Hosie)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Non arithmetic integer type.
  5. Date: 19 Mar 1996 01:41:38 +1200
  6. Organization: Airdmhor : a couple of BBS's, a bunch of people, and a cat.
  7. Message-ID: <4ijp6i$cdu@airdmhor.gen.nz>
  8. References: <4igp11$83a@airdmhor.gen.nz> <4ihfjcINNss6@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: airdmhor.gen.nz
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. In article <4igp11$83a@airdmhor.gen.nz>,
  13. Simon Hosie <gumboot@airdmhor.gen.nz> wrote:
  14. >   I've been trying to create a data type that holds an int or intlike chunk
  15. > of data that is incompatible with any other types (to generate errors if
  16. > someone assumes that it's the same type as an int).. I've found that
  17. >
  18. > typedef struct { int Value; } TypeA;
  19. > typedef struct { int ValueWithADifferentName; } TypeB;
  20. >   makes two compatible types; a variable of TypeA can be assigned to a
  21. > variable of TypeB without any warnings.. but
  22.  
  23. Kazimir Kylheku:
  24. > Your compiler has a gratuitous extension that allows for structural
  25. > equivalence type checking.
  26.  
  27. > In standard C, structures with a different tag name are different.  Structures
  28. > declard with _no tag_ are always incompatible with each other and with other
  29. > structures that have tags.
  30.  
  31.   So, do you reckon that if I gave then tags that were _different_ rather
  32. than absent then they would have another chance at being recognised as
  33. different?  [Jumps to D*S shell..]  Nope..  Let's try unions..  Nope..  .CPP
  34. extention..  Got it.
  35.  
  36.   Is it a C rule or a C++ rule that they be incompatible?
  37.